---
title: "Enclave_Prop"
author: "melissa_barales" 
output: pdf_document
---   

 
```{r}
setwd("~/Desktop/Senior Thesis/Data/Pooled CES")
```

```{r}
library(haven)
library(dplyr)
library(tidyverse)
library(stargazer)
```

**Enclave residency as a proportion**

**Loading in Data**

```{r}
#loading in CES data
dat <- readRDS("Pooled Data.rds")
```

```{r}
#loading in crosswalk file
crosswalk <- read.csv("geocorr2014_2202404250.csv", stringsAsFactors=FALSE)
```

```{r}
#creating a puma identifier variable in crosswalk file
crosswalk <-  crosswalk %>% unite("puma_2", state, puma12, sep= "-", 
        remove = FALSE)
```

```{r}
#loading in dataset of all Hispanic enclaves (contains PUMAs that have enclaves)
Hisp_enclaves <- read.csv("Hisp_enclaves.csv")
```

```{r}
#creating an enclave residency variable in crosswalk file 
#1 - yes lives in an enclave 
#0 - no does not live in an enclave
crosswalk_merged <- crosswalk %>% 
  mutate(enclave_res = ifelse (puma_2 %in% Hisp_enclaves$puma_2, 1, 0))
```

```{r}
table(crosswalk_merged$enclave_res)
```

```{r}
#Adding in the proportion of a puma's population that is made up of  a 
#Hispanic enclave to dataset of cross_walk merged
Hisp_enclaves <- Hisp_enclaves %>% select(puma_2, prop)

crosswalk_merged <- crosswalk_merged %>% 
  left_join(Hisp_enclaves, by="puma_2" )
```

```{r}
hist(crosswalk_merged$prop)
```

```{r}
#Recoding all pumas that do not have Hispanic enclaves in them to 0
crosswalk_merged$prop[is.na(crosswalk_merged$prop)] <- 0
```

```{r}
#Calculating a variable that sums the proportion of a zipcode's population
#that resides within an enclave 
crosswalk_pop <- crosswalk_merged %>%
  mutate(enclave_pop=(pop14 * prop)) %>%
  group_by(puma_2) %>%
  summarise(puma_prop=(sum(enclave_pop) / sum(pop14)))
```
```{r}
#NOTE THAT THERE ARE A TOTAL OF 2,351 PUMAS IN CROSSWALK POP 
#SAME AS ACS FIlE
```

```{r}
#Merging in this variable to crosswalk file
crosswalk <- crosswalk %>% 
  left_join(crosswalk_pop, by="puma_2") 
```

```{r}
#creating an enclave indicator that calculates a PUMA's
#proportion of a Hispanic enclave falling within a zipcode 
ex <- subset(crosswalk, crosswalk$zcta5=="85007")
```

```{r}
ex_1 <- ex %>% group_by(zcta5) %>% 
  summarize(zip_prop = weighted.mean(puma_prop, pop14))
```


```{r}
#creating an enclave indicator that calculates a PUMA's
#proportion of a Hispanic enclave falling within a zipcode 
crosswalk_zip <- crosswalk %>% 
  filter(zcta5!=99999) %>% 
  group_by (zcta5) %>% 
  summarize(zip_prop = weighted.mean(puma_prop, pop14), num = n())
```

```{r}
table(crosswalk_zip$num)
```

```{r}
crosswalk_zip_1 <- subset(crosswalk_zip, crosswalk_zip$zip_prop>0)
```

```{r}
table(crosswalk_zip_1$num)
```

```{r}
prop.table(table(crosswalk_zip_1$num))
```

```{r}
#renaming zipcode in CES data
dat <- dat %>% mutate(zcta5=zipcode)
```

```{r}
crosswalk_zip$zcta5 <- as.character(crosswalk_zip$zcta5)
```

```{r}
#merging in zip_prop variable to CES
dat <- dat %>% 
  left_join(crosswalk_zip, by="zcta5")
```

```{r}
dat$zip_prop[is.na(dat$zip_prop)] <- 0
```

```{r}
#recoding control variables in CES
```

```{r}
#making new education variable
dat$educ2 <- NA
dat$educ2[dat$educ==1] <- "a - No HS"
dat$educ2[dat$educ==2] <- "b - HS Grad"
dat$educ2[dat$educ==3 | dat$educ==4] <- "c - Some College"
dat$educ2[dat$educ==5] <- "d - 4 yr"
dat$educ2[dat$educ==6] <- "e - Post-grad"
```

```{r}
dat$educ2 <- as.factor(dat$educ2)
```


```{r}
#making a new race variable 

dat$race2 <- NA
dat$race2[dat$race==1] <- "a - White"
dat$race2[dat$race==2] <- "b - Black"
dat$race2[dat$race==3] <- "c - Hispanic"
dat$race2[dat$race==4] <- "d - Asian"
dat$race2[dat$race==5] <- "e - Native American"
dat$race2[dat$race==6] <- "f - Mixed"
dat$race2[dat$race==7] <- "e - Other"
dat$race2[dat$race==8] <- "f - Middle Eastern"
```

```{r}
dat$race2 <- as.factor(dat$race2)
```

```{r}
#Recoding pid 
dat$pid <- NA
dat$pid[dat$pid7== 1 | dat$pid7== 2 | dat$pid7== 3] <- "b - Democrat"
dat$pid[dat$pid7== 4] <- "a - Independent"
dat$pid[dat$pid7== 5 | dat$pid7== 6 | dat$pid7== 7] <- "c - Republican"
```

```{r}
dat$pid <- as.factor(dat$pid)
```

```{r}
dat$age2 <- dat$age^2
```

```{r}
#recoding outcome variables
```


```{r}
#new turnout variable
dat$turnout2 <- NA
dat$turnout2[dat$vv_turnout_gvm2==2] <- 1
dat$turnout2[dat$vv_turnout_gvm2==1] <- 2
```

```{r}
table(dat$turnout2)
```

```{r}
#new reg variable 
dat$registration <- NA
dat$registration[dat$vv_regstatus==1] <- 2
dat$registration[dat$vv_regstatus== 2 | dat$vv_regstatus== 3 |
                   dat$vv_regstatus== 4 | dat$vv_regstatus== 5 |
                   dat$vv_regstatus== 6]  <- 1
```

**other political outcomes**

```{r}
#recoding order of variables
#Politcal Meeting 
dat$political_meeting <- as.numeric(dat$political_meeting)
dat$political_meeting[dat$political_meeting==1] <- 1
dat$political_meeting[dat$political_meeting==2] <- 0
```

```{r}
#Politcal Sign
dat$political_sign <- as.numeric(dat$political_sign)
dat$political_sign[dat$political_sign==2] <- 0
```

```{r}
#volunteer campaign 
dat$campaign_volunteer <- as.numeric(dat$campaign_volunteer)
dat$campaign_volunteer[dat$campaign_volunteer==2] <- 0
```

```{r}
#Political Protest
dat$political_protest <- as.numeric(dat$political_protest)
dat$political_protest[dat$political_protest==2] <- 0
```

```{r}
#Political Contact
dat$political_contact <- as.numeric(dat$political_contact)
dat$political_contact[dat$political_contact==2] <- 0
```

```{r}
#Political Donation
dat$political_donation <- as.numeric(dat$political_donation)
dat$political_donation[dat$political_donation==2] <- 0
```

```{r}
#Social Media - post
dat$sm_post <- as.numeric(dat$sm_post)
dat$sm_post[dat$sm_post==2] <- 0
```

```{r}
#Social Media - story
dat$sm_story <- as.numeric(dat$sm_story)
dat$sm_story[dat$sm_story==2] <- 0
```

```{r}
#Social Media - event
dat$sm_event <- as.numeric(dat$sm_event)
dat$sm_event[dat$sm_event==2] <- 0
```

```{r}
#Social Media - comment
dat$sm_comment <- as.numeric(dat$sm_comment)
dat$sm_comment[dat$sm_comment==2] <- 0
```

```{r}
#Social Media - forward
dat$sm_forward <- as.numeric(dat$sm_forward)
dat$sm_forward[dat$sm_forward==2] <- 0
```

```{r}
#other political attitudes 
table(dat$approval_gov)
```

```{r}
dat$approval_gov_1 <- NA
dat$approval_gov_1[dat$approval_gov== 1 | 
                     dat$approval_gov== 2] <- 1
dat$approval_gov_1[dat$approval_gov== 3 | 
                     dat$approval_gov== 4] <- 0
```


```{r}
dat$approval_pres_1 <- NA
dat$approval_pres_1[dat$approval_pres== 1 | 
                     dat$approval_pres== 2] <- 1
dat$approval_pres_1[dat$approval_pres== 3 | 
                     dat$approval_pres== 4] <- 0
```

```{r}
dat$approval_rep_1 <- NA
dat$approval_rep_1[dat$approval_rep== 1 | 
                     dat$approval_rep== 2] <- 1
dat$approval_rep_1[dat$approval_rep== 3 | 
                     dat$approval_rep== 4] <- 0
```

```{r}
dat$approval_sen1_1 <- NA
dat$approval_sen1_1[dat$approval_sen1== 1 | 
                     dat$approval_sen1== 2] <- 1
dat$approval_sen1_1[dat$approval_sen1== 3 | 
                     dat$approval_sen1== 4] <- 0
```

```{r}
dat$approval_sen2_1 <- NA
dat$approval_sen2_1[dat$approval_sen2== 1 | 
                     dat$approval_sen2== 2] <- 1
dat$approval_sen2_1[dat$approval_sen2== 3 | 
                     dat$approval_sen2== 4] <- 0
```

```{r}
dat$att_congress_1 <- NA
dat$att_congress_1[dat$att_congress== 1 | 
                     dat$att_congress== 2] <- 1
dat$att_congress_1[dat$att_congress== 3 | 
                     dat$att_congress== 4] <- 0
```

```{r}
dat$att_supreme_1 <- NA
dat$att_supreme_1[dat$att_supreme== 1 | 
                     dat$att_supreme== 2] <- 1
dat$att_supreme_1[dat$att_supreme== 3 | 
                     dat$att_supreme== 4] <- 0
```

```{r}
table(dat$newsint)
```

```{r}
dat$newsint_1 <- NA
dat$newsint_1[dat$newsint==4] <- 1
dat$newsint_1[dat$newsint==3] <- 2
dat$newsint_1[dat$newsint==2] <- 3
dat$newsint_1[dat$newsint==1] <- 4
```

```{r}
table(dat$newsint_1)
```

```{r}
table(dat$state)
```

```{r}
dat$state <- haven::as_factor(dat$state)
```

```{r}
table(dat$state)
```


```{r}
dat$ideo5_new <- NA
dat$ideo5_new[dat$ideo5==6] <- "a - unsure"
dat$ideo5_new[dat$ideo5== 1 | dat$ideo5== 2] <- "b - liberal"
dat$ideo5_new[dat$ideo5== 4 | dat$ideo5== 5] <- "c - conservative"
dat$ideo5_new[dat$ideo5== 3] <- "d - moderate"
```

```{r}
table(dat$ideo5_new)
```

```{r}
dat$has_child2 <- NA
dat$has_child2[dat$has_child== 2] <- "a - no children"
dat$has_child2[dat$has_child== 1] <- "b - children "
```

```{r}
table(dat$has_child2)
```

```{r}
dat$ownhome2 <- NA
dat$ownhome2[dat$ownhome==1] <- "b - own home"
dat$ownhome2[dat$ownhome==2 | dat$ownhome==3] <- "a - don't own"
```

```{r}
table(dat$ownhome2)
```

```{r}
dat$employ2 <- NA
dat$employ2[dat$employ== 1 | dat$employ==2] <- "b - employed"
dat$employ2[dat$employ== 3 | dat$employ==4] <- "a - unemployed"
```

```{r}
table(dat$employ2)
```

```{r}
#subsetting data to purely Hispanic respondents
dat <- subset(dat, dat$race_new==3)
```

```{r}
#subsetting to first or second-gen immigrants 
dat2 <- subset(dat, dat$imm_status==1)
```

```{r}
dat2$second_gen <- NA
dat2$second_gen[dat2$immstat<3] <- 0
dat2$second_gen[dat2$immstat==3] <- 1
```

```{r}
table(dat2$second_gen)
```

**Enclave residency as a proportion**

**Immigrant populaiton**

*MULTIVARIATE REGRESSIONS*


```{r}
#General Turnout 
gen_turnout_1 <- lm(data= dat2, zip_prop ~ turnout2 + pid + gender + 
                      age + age2 +
                    educ2 +  
                  + faminc + citizen + second_gen)
```

```{r}
summary(gen_turnout_1)
```

```{r echo=FALSE, results='asis'}
stargazer(gen_turnout_1, type = "text")
```


```{r}
#Voter Registration 
reg_status <- lm(data= dat2, zip_prop ~ registration + pid + gender + 
                      age + age2 +
                    educ2 +  
                  + faminc + citizen + second_gen)
```

```{r}
summary(reg_status)
```

```{r echo=FALSE, results='asis'}
stargazer(reg_status, type = "text") 
```

```{r}
#Political Meetings 
pol_meeting <- lm(data= dat2, zip_prop ~ political_meeting + pid + gender + 
                      age + age2 +
                    educ2 +  
                  + faminc + citizen + second_gen)
```

```{r}
summary(pol_meeting)
```

```{r echo=FALSE, results='asis'}
stargazer(pol_meeting, type = "text")
```

```{r}
#Political Sign
pol_sign <- lm(data= dat2, zip_prop  ~ political_sign + pid + gender + 
                      age + age2 +
                    educ2 +  
                  + faminc + citizen + second_gen)
```

```{r}
summary(pol_sign)
```

```{r echo=FALSE, results='asis'}
stargazer(pol_sign, type = "text")
```

```{r}
#Campaign Volunteer
camp_volunteer <- lm(data= dat2, zip_prop ~ campaign_volunteer +
                   pid + gender + 
                      age + age2 +
                    educ2 +  
                  + faminc + citizen + second_gen)
```

```{r}
summary(camp_volunteer)
```

```{r echo=FALSE, results='asis'}
stargazer(camp_volunteer, type = "text")
```

```{r}
#Political Protest
pol_protest <- lm(data= dat2, zip_prop ~ political_protest +
                   pid + gender + 
                      age + age2 +
                    educ2 +  
                  + faminc + citizen + second_gen)
```

```{r}
summary(pol_protest)
```

```{r echo=FALSE, results='asis'}
stargazer(pol_protest, type = "text")
```

```{r}
#Political Contact
pol_contact <- lm(data= dat2, zip_prop ~ political_contact +
                   pid + gender + 
                      age + age2 +
                    educ2 +  
                  + faminc + citizen + second_gen) 
```

```{r}
summary(pol_contact)
```

```{r echo=FALSE, results='asis'}
stargazer(pol_contact, type = "text")
```

```{r}
#Political Donation
pol_donation <- lm(data= dat2, zip_prop ~ political_donation + 
                   pid + gender + 
                      age + age2 +
                    educ2 +  
                  + faminc + citizen + second_gen)
```

```{r}
summary(pol_donation)
```

```{r echo=FALSE, results='asis'}
stargazer(pol_donation, type = "text")
```


```{r}
#Approval -- pres
approval_pres <- lm(data= dat2, zip_prop ~ approval_pres_1 + pid + gender + 
                      age + age2 +
                    educ2 +  
                  + faminc + citizen + second_gen)
```

```{r}
summary(approval_pres)
```

```{r echo=FALSE, results='asis'}
stargazer(approval_pres, type = "text")
```

```{r}
#Approval -- rep 
approval_rep <- lm(data= dat2, zip_prop ~ approval_rep_1 + pid + gender + 
                      age + age2 +
                    educ2 +  
                  + faminc + citizen + second_gen)
```

```{r}
summary(approval_rep)
```

```{r echo=FALSE, results='asis'}
stargazer(approval_rep, type = "text")
```

```{r}
#Approval -- sen1
approval_sen1 <- lm(data= dat2, zip_prop ~ approval_sen1_1 + pid + gender + 
                      age + age2 +
                    educ2  
                  + faminc + citizen + second_gen)
```

```{r}
summary(approval_sen1)
```

```{r echo=FALSE, results='asis'}
stargazer(approval_sen1, type = "text")
```

```{r}
#Approval -- sen2 
approval_sen2 <- lm(data= dat2, zip_prop ~ approval_sen2_1 + pid + gender + 
                      age + age2 +
                    educ2  
                  + faminc + citizen + second_gen) 
```

```{r}
summary(approval_sen2)
```

```{r echo=FALSE, results='asis'}
stargazer(approval_sen2, type = "text")
```

```{r}
#Approval -- governor
approval_gov <- lm(data= dat2, zip_prop ~ approval_gov_1 + pid + gender + 
                      age + age2 +
                    educ2 +  
                  + faminc + citizen + second_gen)
```

```{r}
summary(approval_gov)
```

```{r echo=FALSE, results='asis'}
stargazer(approval_gov, type = "text")
```

```{r}
#Approval -- Congress
approval_congress <- lm(data= dat2, zip_prop ~ att_congress_1 + pid + gender + 
                      age + age2 +
                    educ2 +  
                  + faminc + citizen + second_gen)
```

```{r}
summary(approval_congress)
```

```{r echo=FALSE, results='asis'}
stargazer(approval_congress, type = "text")
```

```{r}
#Approval -- Supreme Court
approval_supremec <- lm(data= dat2, zip_prop ~ att_supreme_1 + pid + gender + 
                      age + age2 +
                    educ2 +  
                  + faminc + citizen + second_gen)
```

```{r}
summary(approval_supremec)
```

```{r echo=FALSE, results='asis'}
stargazer(approval_supremec, type = "text")
```

```{r}
#Interest in Politics 
newsint <- lm(data= dat2, zip_prop ~ newsint_1 + pid + gender + 
                      age + age2 +
                    educ2 +  
                  + faminc + citizen + second_gen)
```

```{r}
summary(newsint)
```

```{r echo=FALSE, results='asis'}
stargazer(newsint, type = "text")
```

```{r}
#Social Media - Comment 
sm_comment <- lm(data= dat2, zip_prop ~ sm_comment + pid + gender + 
                      age + age2 +
                    educ2 +  
                  + faminc + citizen + second_gen)
```

```{r}
summary(sm_comment)
```

```{r echo=FALSE, results='asis'}
stargazer(sm_comment, type = "text")
```

```{r}
sm_story <- lm(data= dat2, zip_prop ~ sm_story + pid + gender + 
                      age + age2 +
                    educ2 +  
                  + faminc + citizen + second_gen)
```

```{r}
summary(sm_story)
```

```{r echo=FALSE, results='asis'}
stargazer(sm_story, type = "text")
```

```{r}
sm_event <- lm(data= dat2, zip_prop ~ sm_event + pid + gender + 
                      age + age2 +
                    educ2 +  
                  + faminc + citizen + second_gen)
```

```{r}
summary(sm_event)
```

```{r echo=FALSE, results='asis'}
stargazer(sm_event, type = "text")
```

```{r}
sm_post <- lm(data= dat2, zip_prop ~ sm_post + pid + gender + 
                      age + age2 +
                    educ2 +  
                  + faminc + citizen + second_gen)
```

```{r}
summary(sm_post)
```

```{r echo=FALSE, results='asis'}
stargazer(sm_post, type = "text")
```

```{r}
sm_forward <- lm(data= dat2, zip_prop ~ sm_forward + pid + gender + 
                      age + age2 +
                    educ2 +  
                  + faminc + citizen + second_gen)
```

```{r}
summary(sm_forward)
```

```{r echo=FALSE, results='asis'}
stargazer(sm_forward, type = "text")
```

```{r}
stargazer(gen_turnout_1, reg_status, pol_meeting, pol_donation, pol_contact, 
          pol_protest, pol_sign, camp_volunteer, sm_post, sm_comment, 
          sm_story, sm_event, sm_forward, 
          dep.var.labels = c("General Turnout", 
                             "Voter Registration", "Political Meeting",
                            "Political Donation", 
                            "Contact Public Official", "Political Protest",
                            "Political Sign", "Campaign Volunteer", "SM: Political Post", 
                            "SM: Political Comment", 
                            "SM: Consume Political Content", 
                            "SM: Follow Political Event", 
                            "SM: Share Political Content"),
          covariate.labels = c("Enclave Residency", "Democrat", 
                               "Republican", "Sex (Female)", 
          "Age", "Age Squared", "High School Degree", "Some College", 
          "College Degree", "Postgraduate", 
          "Family Income", "Non-citizen", "Second-Generation"), align=TRUE,
          title="Effect of Enclave Residency on Political Behaviors", 
          type = "text",
          out = "combined_pol_model_imm_prop.htm")
```

```{r}
stargazer(newsint, approval_pres, approval_congress, 
          approval_supremec, approval_sen1, approval_sen2, approval_rep, 
          approval_gov, 
          dep.var.labels = c("Interest in Politics", "President Approval", 
                             "Congress Approval", "Supreme Court Approval",
                            "Senator 1 Approval", "Senator 2 Approval",
                            "House Representative Approval", 
                            "Governor Approval"),
          covariate.labels = c("Enclave Residency", "Democrat", 
                               "Republican", "Sex (Female)", 
          "Age", "Age Squared", "High School Degree", "Some College", 
          "College Degree", "Postgraduate", 
          "Family Income", "Non-citizen", "Second-Generation"), align=TRUE,
          title="Effect of Enclave Residency on Immigrants' Political Attitudes", 
          type = "text",
          out = "combined_att_model_imm_prop.htm")
```



```{r}
dwplot(list(gen_turnout_1, reg_status, pol_meeting, pol_donation, 
            pol_contact, camp_volunteer, pol_protest, pol_sign, sm_post,
            sm_story, sm_comment, sm_forward, sm_event),
       ci = 0.95,
       vline = geom_vline(
           xintercept = 0,
           colour = "grey60",
           linetype = 2
       ),
       vars_order = c("turnout2","registration", 
                      "political_meeting", "political_donation","political_contact",
                     "campaign_volunteer", "political_protest", "political_sign", "sm_post",
                     "sm_story", "sm_comment", "sm_forward", "sm_event"
                    )
        ) %>% 
        relabel_predictors( 
                      c(turnout2 = "General Turnout",
                            registration = "Voter Registration",
                            political_meeting = "Political Meeting",
                            political_donation = "Political Donation",
                            political_contact = "Contact Public Official",
                            campaign_volunteer = "Campaign Volunteer",
                            political_protest = "Political Protest",
                            political_sign = "Political Sign",
                            sm_post = "SM: Political Post",
                            sm_story = "SM: Consume Political Content",
                            sm_comment = "SM: Political Comment" ,
                            sm_forward = "SM: Share Political Content",
                            sm_event = "SM: Follow Political Events") 
          )+  
    xlab("Coefficient Estimate") + ylab("Political Behaviors") +
      geom_vline(xintercept = 0,
               colour = "grey60",
               linetype = 2) +
    scale_colour_hue(
        name = "Model",
        labels = c("General Turnout", "Voter Registration", 
                   "Politcal Meeting", "Political Donation",
                   "Contact Public Official", "Campaign Volunteer",
                   "Political Protest", "Political Sign", 
                   "SM: Political Post", "SM: Consume Political Content",
                   "SM: Political Comment", "SM: Share Political Content","SM: Follow Political Events")
     )
```

```{r}
dwplot(list(approval_pres, approval_congress, approval_supremec, approval_sen1, 
            approval_sen2, approval_rep, approval_gov, newsint),
       ci = 0.95,
       vline = geom_vline(
           xintercept = 0,
           colour = "grey60",
           linetype = 2
       ),
       vars_order = c("approval_pres_1", "att_congress_1", 
                     "att_supreme_1", "approval_sen1_1", 
            "approval_sen2_1", "approval_rep_1", "approval_gov_1", "newsint_1")
      ) %>% 
          relabel_predictors (
            c(approval_pres_1 = "President Approval",
                             att_congress_1 = "Congress Approval",
                             att_supreme_1 = "Supreme Court Approval",
                             approval_sen1_1 = "Senator 1 Approval",
                             approval_sen2_1 = "Senator 2 Approval",
                             approval_rep_1 = "Congressmember Approval",
                             approval_gov_1 = "Governor Approval",
                             newsint_1 = "Political Interest") 
           ) + 
    xlab("Coefficient Estimate") + ylab("Political Attitudes") +
      geom_vline(xintercept = 0,
               colour = "grey60",
               linetype = 2) +
    scale_colour_hue(
        name = "Model",
        labels = c("President Approval", "Congress Approval",
                   "Supreme Court Approval", "Senator 1 Approval",
                   "Senator 2 Approvaal","Congressmember Approval",
                   "Governor Approval", "Political Interest")
    )
```


**STATE & NO EXTRA CONTROLS**

```{r}
#General Turnout 
gen_turnout_1 <- lm(data= dat2, zip_prop ~ turnout2 + pid + gender + 
                      age + age2 +
                    educ2 +  
                  + faminc + citizen + second_gen + state)
```

```{r}
summary(gen_turnout)
```

```{r echo=FALSE, results='asis'}
stargazer(gen_turnout, type = "text")
```



```{r}
#Voter Registration 
reg_status <- lm(data= dat2, zip_prop ~ registration + pid + gender + 
                      age + age2 +
                    educ2 +  
                  + faminc + citizen + second_gen + state)
```

```{r}
summary(reg_status)
```

```{r echo=FALSE, results='asis'}
stargazer(reg_status, type = "text")
```

```{r}
#Political Meetings 
pol_meeting <- lm(data= dat2, zip_prop ~ political_meeting + pid + gender + 
                      age + age2 +
                    educ2 +  
                  + faminc + citizen + second_gen + state)
```

```{r}
summary(pol_meeting)
```

```{r echo=FALSE, results='asis'}
stargazer(pol_meeting, type = "text")
```

```{r}
#Political Sign
pol_sign <- lm(data= dat2, zip_prop ~ political_sign + pid + gender + 
                      age + age2 +
                    educ2 +  
                  + faminc + citizen + second_gen + state)
```

```{r}
summary(pol_sign)
```

```{r echo=FALSE, results='asis'}
stargazer(pol_sign, type = "text")
```

```{r}
#Campaign Volunteer
camp_volunteer <- lm(data= dat2, zip_prop ~ campaign_volunteer +  
                   pid + gender + 
                      age + age2 +
                    educ2 +  
                  + faminc + citizen + second_gen + state)
```

```{r}
summary(camp_volunteer)
```

```{r echo=FALSE, results='asis'}
stargazer(camp_volunteer, type = "text")
```

```{r}
#Political Protest
pol_protest <- lm(data= dat2, zip_prop ~ political_protest + 
                   pid + gender + 
                      age + age2 +
                    educ2 +  
                  + faminc + citizen + second_gen + state)
```

```{r}
summary(pol_protest)
```

```{r echo=FALSE, results='asis'}
stargazer(pol_protest, type = "text")
```

```{r}
#Political Contact
pol_contact <- lm(data= dat2, zip_prop ~ political_contact +
                   pid + gender + 
                      age + age2 +
                    educ2 +  
                  + faminc + citizen + second_gen + state)
```

```{r}
summary(pol_contact)
```

```{r echo=FALSE, results='asis'}
stargazer(pol_contact, type = "text")
```

```{r}
#Political Donation
pol_donation <- lm(data= dat2, zip_prop ~ political_donation + 
                   pid + gender + 
                      age + age2 +
                    educ2 +  
                  + faminc + citizen + second_gen + state)
```

```{r}
summary(pol_donation)
```

```{r echo=FALSE, results='asis'}
stargazer(pol_donation, type = "text")
```


```{r}
#Approval -- pres
approval_pres <- lm(data= dat2, zip_prop ~ approval_pres_1 + pid + gender + 
                      age + age2 +
                    educ2 +  
                  + faminc + citizen + second_gen + state)
```

```{r}
summary(approval_pres)
```

```{r echo=FALSE, results='asis'}
stargazer(approval_pres, type = "text")
```

```{r}
#Approval -- rep 
approval_rep <- lm(data= dat2, zip_prop ~ approval_rep_1 + pid + gender + 
                      age + age2 +
                    educ2 +  
                  + faminc + citizen + second_gen + state)
```

```{r}
summary(approval_rep)
```

```{r echo=FALSE, results='asis'}
stargazer(approval_rep, type = "text")
```

```{r}
#Approval -- sen1
approval_sen1 <- lm(data= dat2, zip_prop ~ approval_sen1_1 + pid + gender + 
                      age + age2 +
                    educ2   
                  + faminc + citizen + second_gen +  state)
```

```{r}
summary(approval_sen1)
```

```{r echo=FALSE, results='asis'}
stargazer(approval_sen1, type = "text")
```

```{r}
#Approval -- sen2 
approval_sen2 <- lm(data= dat2, zip_prop ~ approval_sen2_1 + pid + gender + 
                      age + age2 +
                    educ2 +  
                  + faminc + citizen + second_gen + state) 
```

```{r}
summary(approval_sen2)
```

```{r echo=FALSE, results='asis'}
stargazer(approval_sen2, type = "text")
```

```{r}
#Approval -- governor
approval_gov <- lm(data= dat2, zip_prop  ~ approval_gov_1 + pid + gender + 
                      age + age2 +
                    educ2  
                  + faminc + citizen + second_gen + state)
```

```{r}
summary(approval_gov)
```

```{r echo=FALSE, results='asis'}
stargazer(approval_gov, type = "text")
```

```{r}
#Approval -- Congress
approval_congress <- lm(data= dat2, zip_prop ~ att_congress_1 + pid + gender + 
                      age + age2 +
                    educ2  
                  + faminc + citizen + second_gen + state)
```

```{r}
summary(approval_congress)
```

```{r echo=FALSE, results='asis'}
stargazer(approval_congress, type = "text")
```

```{r}
#Approval -- Supreme Court
approval_supremec <- lm(data= dat2, zip_prop ~ att_supreme_1 + pid + gender + 
                      age + age2 +
                    educ2  
                  + faminc + citizen + second_gen + state)
```

```{r}
summary(approval_supremec)
```

```{r echo=FALSE, results='asis'}
stargazer(approval_supremec, type = "text")
```

```{r}
#Interest in Politics 
newsint <- lm(data= dat2, zip_prop ~ newsint_1 + pid + gender + 
                      age + age2 +
                    educ2 + faminc + citizen + second_gen + state)
```

```{r}
summary(newsint)
```

```{r echo=FALSE, results='asis'}
stargazer(newsint, type = "text")
```

```{r}
#Social Media - Comment 
sm_comment <- lm(data= dat2, zip_prop ~ sm_comment + pid + gender + 
                      age + age2 +
                    educ2 + faminc + citizen + second_gen + state)
```

```{r}
summary(sm_comment)
```

```{r echo=FALSE, results='asis'}
stargazer(sm_comment, type = "text")
```

```{r}
sm_story <- lm(data= dat2, zip_prop  ~ sm_story + pid + gender + 
                      age + age2 +
                    educ2 +  faminc + citizen + second_gen + state)
```

```{r}
summary(sm_story)
```

```{r echo=FALSE, results='asis'}
stargazer(sm_story, type = "text")
```

```{r}
sm_event <- lm(data= dat2, zip_prop ~ sm_event + pid + gender + 
                      age + age2 +
                    educ2 + faminc + citizen + second_gen + state)
```

```{r}
summary(sm_event)
```

```{r echo=FALSE, results='asis'}
stargazer(sm_event, type = "text")
```

```{r}
sm_post <- lm(data= dat2, zip_prop ~ sm_post + pid + gender + 
                      age + age2 +
                    educ2 + faminc + citizen + second_gen + state)
```

```{r}
summary(sm_post)
```

```{r echo=FALSE, results='asis'}
stargazer(sm_post, type = "text")
```

```{r}
sm_forward <- lm(data= dat2, zip_prop ~ sm_forward + pid + gender + 
                      age + age2 +
                    educ2 + faminc + citizen + second_gen + state)
```

```{r}
summary(sm_forward)
```

```{r echo=FALSE, results='asis'}
stargazer(sm_forward, type = "text")
```

```{r}
stargazer(gen_turnout_1, reg_status, pol_meeting, pol_donation, 
          pol_contact, pol_protest, pol_sign, camp_volunteer, sm_post, sm_comment, 
          sm_story, sm_event, sm_forward, 
          dep.var.labels = c("General Turnout", 
                             "Voter Registration", "Political Meeting",
                            "Political Donation", 
                            "Contact Public Official", "Political Protest",
                            "Political Sign", "Campaign Volunteer", "SM: Political Post", 
                            "SM: Political Comment", 
                            "SM: Consume Political Content", 
                            "SM: Follow Political Event", 
                            "SM: Share Political Content"),
          covariate.labels = c("Enclave Residency", "Democrat", 
                               "Republican", "Sex (Female)", 
          "Age", "Age Squared", "High School Degree", "Some College", 
          "College Degree", "Postgraduate", 
          "Family Income", "Non-citizen", "Second-Generation", "State"), align=TRUE,
          title="Effect of Enclave Residency on Political Behaviors", 
          type = "text",
          out = "state_pol_model_prop.htm")
```

```{r}
stargazer(newsint, approval_pres, approval_congress, 
          approval_supremec, approval_sen1, approval_sen2, approval_rep, 
          approval_gov, 
          dep.var.labels = c("Interest in Politics", "President Approval", 
                             "Congress Approval", "Supreme Court Approval",
                            "Senator 1 Approval", "Senator 2 Approval",
                            "House Representative Approval", 
                            "Governor Approval"),
          covariate.labels = c("Enclave Residency", "Democrat", 
                               "Republican", "Sex (Female)", 
          "Age", "Age Squared", "High School Degree", "Some College", 
          "College Degree", "Postgraduate", 
          "Family Income", "Non-citizen", "Second-Generation", "State"), align=TRUE,
          title="Effect of Enclave Residency on Immigrants' Political Attitudes", 
          type = "text",
          out = "state_att_model_prop.htm")
```

```{r}
dwplot(list(gen_turnout_1, reg_status, pol_meeting, pol_donation, 
            pol_contact, camp_volunteer, pol_protest, pol_sign, sm_post,
            sm_story, sm_comment, sm_forward, sm_event),
       ci = 0.95,
       vline = geom_vline(
           xintercept = 0,
           colour = "grey60",
           linetype = 2
       ),
       vars_order = c("turnout2","registration", 
                      "political_meeting", "political_donation","political_contact",
                     "campaign_volunteer", "political_protest", "political_sign", "sm_post",
                     "sm_story", "sm_comment", "sm_forward", "sm_event"
                    )
        ) %>% 
        relabel_predictors( 
                      c(turnout2 = "General Turnout",
                            registration = "Voter Registration",
                            political_meeting = "Political Meeting",
                            political_donation = "Political Donation",
                            political_contact = "Contact Public Official",
                            campaign_volunteer = "Campaign Volunteer",
                            political_protest = "Political Protest",
                            political_sign = "Political Sign",
                            sm_post = "SM: Political Post",
                            sm_story = "SM: Consume Political Content",
                            sm_comment = "SM: Political Comment" ,
                            sm_forward = "SM: Share Political Content",
                            sm_event = "SM: Follow Political Events") 
          )+  
    xlab("Coefficient Estimate") + ylab("Political Behaviors") +
      geom_vline(xintercept = 0,
               colour = "grey60",
               linetype = 2) +
    scale_colour_hue(
        name = "Model",
        labels = c("General Turnout", "Voter Registration", 
                   "Politcal Meeting", "Political Donation",
                   "Contact Public Official", "Campaign Volunteer",
                   "Political Protest", "Political Sign", 
                   "SM: Political Post", "SM: Consume Political Content",
                   "SM: Political Comment", "SM: Share Political Content","SM: Follow Political Events")
     )
```


```{r}
dwplot(list(approval_pres, approval_congress, approval_supremec, approval_sen1, 
            approval_sen2, approval_rep, approval_gov, newsint),
       ci = 0.95,
       vline = geom_vline(
           xintercept = 0,
           colour = "grey60",
           linetype = 2
       ),
       vars_order = c("approval_pres_1", "att_congress_1", 
                     "att_supreme_1", "approval_sen1_1", 
            "approval_sen2_1", "approval_rep_1", "approval_gov_1", "newsint_1")
      ) %>% 
          relabel_predictors (
            c(approval_pres_1 = "President Approval",
                             att_congress_1 = "Congress Approval",
                             att_supreme_1 = "Supreme Court Approval",
                             approval_sen1_1 = "Senator 1 Approval",
                             approval_sen2_1 = "Senator 2 Approval",
                             approval_rep_1 = "Congressmember Approval",
                             approval_gov_1 = "Governor Approval",
                             newsint_1 = "Political Interest") 
           ) + 
    xlab("Coefficient Estimate") + ylab("Political Attitudes") +
      geom_vline(xintercept = 0,
               colour = "grey60",
               linetype = 2) +
    scale_colour_hue(
        name = "Model",
        labels = c("President Approval", "Congress Approval",
                   "Supreme Court Approval", "Senator 1 Approval",
                   "Senator 2 Approvaal","Congressmember Approval",
                   "Governor Approval", "Political Interest")
    )
```

